home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / Vice.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  3.7 KB  |  193 lines

  1. *******************************************************
  2. **     XFD external decruncher for Vice Cruncher     **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **       shortened and fixed by SDI in 1999           **
  5. **       and fixed by Don Adan/WT in 2000           **
  6. *******************************************************
  7.  
  8. ;        INCLUDE    "AINCLUDE:IncDirs.i"
  9.         INCLUDE    "libraries/xfdmaster.i"
  10.  
  11.         * head function for tests
  12. *        INCLUDE    "xfdExeHead.a"
  13.  
  14. ; xfdForeman structure MUST be first thing in all external decrunchers
  15.  
  16. ForeMan        moveq    #-1,d0        ;security
  17.         rts
  18.         dc.l    XFDF_ID        ;id
  19.         dc.w    1        ;version
  20.         dc.w    0
  21.         dc.l    0,0        ;private
  22.         dc.l    S_Vice        ;first slave
  23.  
  24. **************************************************
  25.  
  26.         dc.b    "$VER: Vice 2.1 (25.08.2000)",0
  27. N_Vice        dc.b    "(Vice) Data Cruncher",0
  28.         even
  29.  
  30. **************************************************
  31.  
  32. ; xfdSlave structure: this one doesn't support segment decrunching
  33.  
  34. S_Vice        dc.l    0        ;no more slaves
  35.         dc.w    2        ;version
  36.         dc.w    39        ;master version
  37.         dc.l    N_Vice        ;name
  38.         dc.w    XFDPFF_DATA!XFDPFF_USERTARGET!XFDPFF_RECOGLEN
  39.         dc.w    0
  40.         dc.l    RB_Vice        ;recog buffer
  41.         dc.l    DB_Vice        ;decrunch buffer
  42.         dc.l    0        ;recog segment
  43.         dc.l    0        ;decrunch segment
  44.         dc.w    0,0
  45.         dc.l    12+2
  46.  
  47. ;-------------------------------------------------
  48.  
  49. ; Recog buffer function: receives buffer + length in a0/d0
  50.  
  51. RB_Vice        CMP.L    #'Vice',(A0)
  52.         BNE.B    .Exit
  53.         CMP.B    #$80,4(A0)
  54.         BNE.B    .Exit
  55.  
  56.     move.l    #$80000,D1
  57.     cmp.l    #100000,D0
  58.     blt.b    .MinMem
  59.     cmp.l    D1,D0
  60.     bgt.b    .MaxMem
  61. .MinMem
  62.     lsr.l    #1,D1
  63.     add.l    D0,D1
  64. .MaxMem
  65.         MOVE.L    D1,xfdrr_MinTargetLen(A1)
  66.         MOVE.L    #-1,xfdrr_FinalTargetLen(A1)
  67.         MOVEQ    #1,D0
  68.     rts
  69. .Exit
  70.         MOVEQ    #0,D0
  71.         RTS
  72.  
  73. ;-------------------------------------------------
  74.  
  75. ;Decrunch buffer function: receives bufferinfo in a0
  76.  
  77. DB_Vice        movem.l    D2-D7/A2-A6,-(A7)
  78.         MOVEA.L    A0,A5
  79.         MOVE.L    xfdbi_SourceBuffer(A5),A6
  80.         MOVE.L    xfdbi_UserTargetBuf(A5),A3    ; dest start
  81.         MOVEA.L    A6,A0
  82.         ADD.L    xfdbi_SourceBufLen(A5),A0    ; source end
  83.         ADDQ.L    #4,A6                ; source start
  84.         MOVE.L    A3,A1
  85.         ADD.L    xfdbi_UserTargetBufLen(A5),A1    ; dest end
  86.  
  87.         MOVE.L    A3,D2
  88.         MOVEM.L    D2/A5,-(a7)
  89.         BSR.B    D_Vice
  90.         MOVEM.L    (A7)+,D2/A5
  91.         MOVE.W    #XFDERR_CORRUPTEDDATA,xfdbi_Error(A5)
  92.  
  93.         SUBA.L    D2,A3
  94.         MOVE.L    A3,xfdbi_TargetBufSaveLen(A5)
  95.  
  96.         ; D0 already set
  97.         MOVEM.L    (A7)+,D2-D7/A2-A6
  98.         RTS
  99.  
  100. D_Vice        LEA    $200(A6),A5
  101.         LEA    $200(A5),A4
  102.         MOVEQ    #1,D6
  103.         MOVE.W    $1FE(A6),D4
  104.         MOVEQ    #$1F,D7
  105.         MOVEQ    #7,D3
  106.  
  107. .Vice01:    MOVEQ    #0,D1
  108.         BSR.S    .ViceSub
  109.         TST.B    D5
  110.         BEQ.S    .Error
  111.         MOVE.B    D5,D1
  112.         BPL.S    .Vice03
  113.         BCLR    D3,D1
  114.         SUBQ.B    #1,D1
  115.         BSR.S    .ViceSub
  116. .Vice02:    CMPA.L    A1,A3
  117.         BGE.B    .DestEnd
  118.         MOVE.B    D5,(A3)+
  119.         DBRA    D1,.Vice02
  120.         BRA.S    .Vice01
  121. .Vice03:    SUBQ.B    #1,D1
  122. .Vice04:    MOVE.W    D4,D5
  123. .Vice05:    LSR.L    #1,D6
  124.         BCC.S    .Vice08
  125.         BEQ.S    .Vice07
  126. .Vice06:    MOVE.W    (A5,D5.W),D5
  127.         BMI.S    .Vice09
  128.         LSR.L    #1,D6
  129.         BCC.S    .Vice08
  130.         BEQ.S    .Vice07
  131.         MOVE.W    (A5,D5.W),D5
  132.         BPL.S    .Vice05
  133.         CMPA.L    A1,A3
  134.         BGE.B    .DestEnd
  135.         MOVE.B    D5,(A3)+
  136.         DBRA    D1,.Vice04
  137.         BRA.S    .Vice01
  138. .Vice07:    MOVE.L    (A4)+,D6
  139.         CMPA.L    A0,A4
  140.         BGT.B    .SourceEnd
  141.         LSR.L    #1,D6
  142.         BSET    D7,D6
  143.         BCS.S    .Vice06
  144. .Vice08:    MOVE.W    (A6,D5.W),D5
  145.         BMI.S    .Vice09
  146.         LSR.L    #1,D6
  147.         BCC.S    .Vice08
  148.         BEQ.S    .Vice07
  149.         MOVE.W    (A5,D5.W),D5
  150.         BPL.S    .Vice05
  151. .Vice09:    CMPA.L    A1,A3
  152.         BGE.B    .DestEnd
  153.         MOVE.B    D5,(A3)+
  154.         DBRA    D1,.Vice04
  155.         BRA.S    .Vice01
  156.  
  157. .DestEnd    MOVEQ    #0,D0
  158.         RTS
  159.  
  160. .SourceEndSub    ADDQ.L    #4,A7
  161. .Error
  162. .SourceEnd    MOVEQ    #1,D0
  163.         RTS
  164.  
  165. .ViceSub:    MOVE.W    D4,D5
  166. .ViceS1:    LSR.L    #1,D6
  167.         BCC.S    .ViceS4
  168.         BEQ.S    .ViceS3
  169. .ViceS2:    MOVE.W    (A5,D5.W),D5
  170.         BMI.S    .End
  171.         LSR.L    #1,D6
  172.         BCC.S    .ViceS4
  173.         BEQ.S    .ViceS3
  174.         MOVE.W    (A5,D5.W),D5
  175.         BPL.S    .ViceS1
  176.         RTS
  177. .ViceS3:    MOVE.L    (A4)+,D6
  178.         CMP.L    A0,A4
  179.         BGT.B    .SourceEndSub
  180.         LSR.L    #1,D6
  181.         BSET    D7,D6
  182.         BCS.S    .ViceS2
  183. .ViceS4:    MOVE.W    (A6,D5.W),D5
  184.         BMI.S    .End
  185.         LSR.L    #1,D6
  186.         BCC.S    .ViceS4
  187.         BEQ.S    .ViceS3
  188.         MOVE.W    (A5,D5.W),D5
  189.         BPL.S    .ViceS1
  190. .End:        RTS
  191.         END
  192.  
  193.